$(function() {
	var k = $(window).height();
	$('#fullpage').fullpage({
		navigation: true,
		afterLoad: function(anchorLink, index) {
			//  		alert(index)
			if(index == 2) {
				$(".seach01").show().animate({
					"right": "350px"
				}, 1000, function() {
					$(this).hide();
					$(".search-sofa").show().animate({
						"bottom": "89%",
						"right": "200px",
						"width": "150px",
						"height": "30px"
					}, 1000);
					$(".sofa02").show().animate({
						"height": "218px"
					}, 1000);
					$(".er0003").animate({
						"opacity":"1"
					},1000)
				})

			}
			if(index==8){
				 $(document).mousemove(function(event) {
				 	var x = event.pageX - $(".ba03").width()/2;
                    var y = event.pageY + 10;  
                   var minY = k - 449; 
                   if(y < minY ) {
                      y = minY;
                   }
                
                 $(".ba03").css({"left": x, "top": y});
              });
              $(".ba01").mouseover(function(){
              	$(".ba001").animate({
              		"opacity":"1"
              	},500);
              })
              $(".ba02").click(function(event){
              	$.fn.fullpage.moveTo(1);
              	$("img, .cover,.er0003,.fugaihe,.seach01,.search-words,.san001 ,.san002,.si03,.si05,.si02,.si005,.wu05,.si01,.wu01,.si04,.qi01,.qi02,.qi001,.liu04,.liu,.wu001").attr("style","");
              });
              
			}
		},
		onLeave: function(index, nextIndex, direction) {
			if(index == 2 && nextIndex == 3) {
				$(".cover").show();
				$(".sofa002").show().animate({
					"bottom": (250 - k) + "px",
					"left": "90px",
					"width": "207px",
					"height": "166px"
				}, 2000, function() {
					$(".san001").animate({
						"opacity":"1"
					}, 500);
					$(".san002").animate({
						"opacity":"1"
					}, 500);
				})
			}
			if(index == 3 && nextIndex == 4) {
				$(".sofa002").hide();
				$(".si04").show().animate({
					"bottom": "28%"
				}, 1000, function() {
					$(".si02").animate({
						"left": [2000, 'easeInOutElastic']
					}, 3000);
					$(".si04").animate({
						"left": [2000, 'easeInOutElastic']
					}, 3000, function() {
						$(".si05").hide(500);
						$(".si03").show(500);
						$(".si003").show(1000);
					})
				});
			}
			if(index == 4 && nextIndex == 5){
				$(".wu02").animate({
					"bottom":"0"
				},2000,function(){
					$(".wu001").animate({
						"opacity":"1"
					},300,function(){
					$(".wu05").show().animate({
						"bottom":"10%"
					},2000)
					$(".wu04").animate({
						"bottom":"55%"
					},2000);
				})
				})
			}
			if(index == 5 && nextIndex == 6){
				$(".liu04").show().animate({
					"left":"40%"
				},2000);
				$(".wu05").animate({
					"bottom":"-350px",
					"left":"42%",
				},2000);
				$(".wu05 img").animate({
					"width":"30px"
				},2000,function(){
					$(".wu05 img").hide();
						$(".liu04").animate({
						"bottom":"5%",
						"left":"40%"
						},2000,function(){
							$(".liu04").hide();
							$(".liu").animate({
								"background-position-x":"100%"
							},3000,function(){
								
								$(".liu08").animate({"opacity":1},500,function(){
									
									$(".liu06").animate({
										"width":252,
										"bottom":"15%",
										"left":"52%"
									},1500);
									$(".liu07").animate({
										"width":"87px",
										"height":"auto" ,
										"bottom":"15%",
										"left":"72%"
									},1500,function(){
										$(".liu09").show(1000);
									});
								})
							})
						});
					})
			}
			if (index == 6 && nextIndex == 7) {
				$(".qi01").show();
				$(".qi001").show().animate({
					"width":0
				},2000,function(){
					$(".qi02").show(500)
				})
			};
			
		}
	});

});